package com.plant.physician.controller;

import com.plant.common.result.Result;
import com.plant.physician.domain.Physician;
import com.plant.physician.service.PhysicianService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/physician")
public class PhysicianController {

    @Autowired
    private PhysicianService physicianService;
    @PostMapping("/insert")
    public Result insert(@RequestBody Physician physician){
        physicianService.insert(physician);
        return Result.ok(physician);
    }

    @GetMapping("/findById/{userId}")
    public Result findById(@PathVariable Integer userId){
        Physician physician = physicianService.findById(userId);
        return Result.ok(physician);
    }

    @GetMapping("/selectPhy")
    public Result selectPhy(){
        List<Physician> list = physicianService.selectPhy();
        return Result.ok(list);
    }

    @PostMapping("/updateStatus")
    public Result updateStatus(@RequestBody Physician physician){
        physicianService.updateStatus(physician);
        return Result.ok();
    }


    @GetMapping("/findAll")
    public List<Physician> findAll(){
        List<Physician> physicianList = physicianService.findAll();
        return physicianList;
    }
}
